package xxl.robotlegs.extensions.viewprocessormap.impl 
{
	import xxl.robotlegs.extensions.matching.api.ITypeFilter;
	import xxl.robotlegs.extensions.viewprocessormap.api.IViewProcessorConfigurator;
	import xxl.robotlegs.extensions.viewprocessormap.api.IViewProcessorMapping;
	/**
	 * ...
	 * @author XXL
	 */
	public class ViewProcessorMapping implements IViewProcessorMapping, IViewProcessorConfigurator
	{
		private var _matcher:ITypeFilter;
		private var _processor:Object;
		private var _processorClass:Class;
		private var _guards:Array = [];
		private var _hooks:Array = [];
		
		public function ViewProcessorMapping(matcher:ITypeFilter, processor:Object) 
		{
			_matcher = matcher;
			setProcessor(processor);
		}
		
		public function toString():String
		{
			return "ViewProcessor " + _processor;
		}
		
		private function setProcessor(processor:Object):void
		{
			if (processor is Class)
			{
				_processorClass = processor as Class;
			}
			else
			{
				_processor = processor;
				_processorClass = processor["constructor"];
			}
		}
		
		/* INTERFACE xxl.robotlegs.extensions.viewprocessormap.api.IViewProcessorConfigurator */
		
		public function withGuards(...guards):IViewProcessorConfigurator 
		{
			_guards = _guards.concat(guards);
			return this;
		}
		
		public function withHooks(...hooks):IViewProcessorConfigurator 
		{
			_hooks = _hooks.concat(hooks);
			return this;
		}
		
		/* INTERFACE xxl.robotlegs.extensions.viewprocessormap.api.IViewProcessorMapping */
		
		public function get matcher():ITypeFilter 
		{
			return _matcher;
		}
		
		public function get processor():Object 
		{
			return _processor;
		}
		
		public function set processor(value:Object):void 
		{
			_processor = value;
		}
		
		public function get processorClass():Class 
		{
			return _processorClass;
		}
		
		public function get guards():Array 
		{
			return _guards;
		}
		
		public function get hooks():Array 
		{
			return _hooks;
		}
		
	}

}